<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">甲方数据变更详情</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="recordDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询"
                                         icon="fa fa-search"
                                         process="@this,startTime,endTime,companyId"
                                         actionListener="#{firstpartyDataInfoBean.onSearch}"
                                         update="@form"/>
                        <p:commandButton id="save" value="提交" icon="fa fa-save" process="@this" update="@form" actionListener="#{firstpartyDataInfoBean.onSubmit}">
                            <p:confirm message="请详细对比变更后数据是否正确，确认变更请不可修改，请确定？" icon="ui-icon-alert" />
                        </p:commandButton>
                        <p:button value="返回" icon="fa fa-reply-all" href="#{currentUserBean.back}"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-g ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12 ">
                    <div class="ui-g-12 card">
                        <h1>请筛选结算日期以及输入公司名称后点击查询</h1>
                        <div class="ui-g-1">
                            <p:outputLabel value="结算日期"/>
                            <strong style="color: red">*</strong>
                        </div>
                        <div class="ui-g-3">
                            <p:calendar value="#{firstpartyDataInfoBean.$.startTime}"
                                        id="startTime" styleClass="autoWidthCalendar"
                                        locale="#{constants:get('LOCALE')}"
                                        timeZone="#{constants:get('TIME_ZONE')}"
                                        pattern="#{constants:get('DATE_FORMAT')}"/>
                            <span>—</span>
                            <p:calendar value="#{firstpartyDataInfoBean.$.endTime}"
                                        id="endTime" styleClass="autoWidthCalendar"
                                        locale="#{constants:get('LOCALE')}"
                                        timeZone="#{constants:get('TIME_ZONE')}"
                                        pattern="#{constants:get('DATE_FORMAT')}"/>
                        </div>

                        <div class="ui-g-1">
                            <p:outputLabel value="公司名称"/>
                            <strong style="color: red">*</strong>
                        </div>
                        <div class="ui-g-3">
                            <p:selectOneMenu id="companyId" value="#{firstpartyDataInfoBean.$.companyId}" filter="true"
                                             filterMatchMode="contains">
                                <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                <f:selectItems value="#{firstpartyDataInfoBean.companyInfoList}"
                                               var="company"
                                               itemLabel="#{company.companyName}" itemValue="#{company.id}"/>
                            </p:selectOneMenu>
                        </div>
                    </div>
                </div>
                <div class="ui-g-12">
                    <div class="ui-g-12 card">
                        <h1>甲方数据变更</h1>
                        <p:dataTable id="recordDataTable"
                                     style="width: 200%;text-align: center"
                                     var="record"
                                     value="#{firstpartyDataInfoBean.firstpartyDataChangeRecordList}"
                                     emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                     scrollable="true"
                                     scrollWidth="97%"
                                     reflow="true"
                                     selection=""
                                     resizableColumns="true"
                                     editable="true">
                            <p:ajax event="rowEdit" listener="#{firstpartyDataInfoBean.onRowEdit}" process="recordDataTable" update="recordDataTable" />
                            <p:column headerText="编辑" style="width:32px">
                                <p:rowEditor />
                            </p:column>
                            <p:column headerText="结算开始日期">
                                <h:outputText value="#{record.settlementStartTime}">
                                    <f:convertDateTime pattern="#{constants:get('DATE_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="结算结束日期">
                                <h:outputText value="#{record.settlementEndTime}">
                                    <f:convertDateTime pattern="#{constants:get('DATE_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="合作模式">
                                <h:outputText
                                        value="#{firstpartyDataInfoBean.translate(DictionaryCode.COOPERATION_MODE,record.copMode)}"/>
                            </p:column>
                            <p:column headerText="结算价格(%)"
                                      rendered="#{firstpartyDataInfoBean.copMode==1 or firstpartyDataInfoBean.copMode==3}">
                                <h:outputText
                                        value="#{record.settlementPercentPrice==null?'-':record.settlementPercentPrice}"/>
                            </p:column>
                            <p:column headerText="结算价格(元)"
                                      rendered="#{firstpartyDataInfoBean.copMode==0 or firstpartyDataInfoBean.copMode==2 or firstpartyDataInfoBean.copMode==3}">
                                <h:outputText
                                        value="#{record.settlementYuanPrice==null?'-':record.settlementYuanPrice}"/>
                            </p:column>
                            <p:column headerText="变更前推广渠道">
                                <h:outputText
                                        value="#{firstpartyDataInfoBean.translate(DictionaryCode.SETTLEMENT_SPREAD_CHANNEL,record.oldSpreadChannel)}"/>
                            </p:column>
                            <p:column headerText="变更后推广渠道">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{firstpartyDataInfoBean.translate(DictionaryCode.SETTLEMENT_SPREAD_CHANNEL,record.newSpreadChannel)}"/>
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:selectOneMenu id="spreadChannel" value="#{record.newSpreadChannel}">
                                            <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                          noSelectionOption="true"/>
                                            <f:selectItems
                                                    value="#{firstpartyDataInfoBean.dictionaries[DictionaryCode.SETTLEMENT_SPREAD_CHANNEL]}"
                                                    var="dic"
                                                    itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                        </p:selectOneMenu>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column headerText="变更前注册数"
                                      rendered="#{firstpartyDataInfoBean.copMode==0 or firstpartyDataInfoBean.copMode==3}">
                                <h:outputText value="#{record.oldRegisterCount}"/>
                            </p:column>
                            <p:column headerText="变更后注册数"
                                      rendered="#{firstpartyDataInfoBean.copMode==0 or firstpartyDataInfoBean.copMode==3}">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{record.newRegisterCount}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText type="number" value="#{record.newRegisterCount}"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>

                            <p:column headerText="变更前放款金额"
                                      rendered="#{firstpartyDataInfoBean.copMode==1 or firstpartyDataInfoBean.copMode==3}">
                                <h:outputText value="#{record.oldLoanAmount}">
                                    <f:convertNumber pattern="###,###.00"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="变更后放款金额"
                                      rendered="#{firstpartyDataInfoBean.copMode==1 or firstpartyDataInfoBean.copMode==3}">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{record.newLoanAmount}">
                                            <f:convertNumber pattern="###,###.00"/>
                                        </h:outputText>
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputNumber  value="#{record.newLoanAmount}"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>

                            <p:column headerText="变更前点击数"
                                      rendered="#{firstpartyDataInfoBean.copMode==2}">
                                <h:outputText value="#{record.oldClickCount}"/>
                            </p:column>
                            <p:column headerText="变更后点击数"
                                      rendered="#{firstpartyDataInfoBean.copMode==2}">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{record.newClickCount}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText type="number" value="#{record.newClickCount}"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>

                            <p:column headerText="变更前结算金额">
                                <h:outputText value="#{record.oldSettlementAmount}">
                                    <f:convertNumber pattern="###,###.00"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="变更后结算金额">
                                <h:outputText value="#{record.newSettlementAmount}">
                                    <f:convertNumber pattern="###,###.00"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="创建时间">
                                <h:outputText value="#{record.firstpartyCreateTime}">
                                    <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="创建人">
                                <h:outputText value="#{record.firstpartyCreator}"/>
                            </p:column>
                            <p:column headerText="备注">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{record.remark}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{record.remark}"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>

                        </p:dataTable>
                       <!-- <div class="ui-g-12">
                            <div class="ui-g-1">变更时间</div>
                            <div class="ui-g-3">
                                <p:inputText></p:inputText>
                            </div>
                            <div class="ui-g-1">变更人</div>
                            <div class="ui-g-3">
                                <p:inputText></p:inputText>
                            </div>
                        </div>-->
                    </div>

                </div>
            </div>
            <p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
                <p:commandButton value="确定" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
                <p:commandButton value="取消" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
            </p:confirmDialog>
        </h:form>
    </ui:define>
</ui:composition>
